from django.db import models
from biglotto.infrastructure.models import BaseModel, Currency

# Create your models here.
class Lottery(BaseModel):
  """
    Defines the lottery class that encapsulates the lottery information.
    It defines when the lottery will create the bets that the people will draw.
  """
  name = models.CharField(max_length=100)
  template = models.TextField(max_length=1000)
  
  class Meta:
    db_table = 'tbl_lotteries'
  
class Draw(BaseModel):
  """
    Defines a draw that the user will game on.
    The draw is the object that will be created every time a lottery has to be played.
    The draw is linked to a lottery and it contains a copy of the template. This is because
    based on the Lottery we will be able to modify the base template and add draws based on different
    parameters. By now, the draws will contain the same template as the lottery.
  """
  lottery = models.ForeignKey(Lottery)
  jackpot_estimated = models.FloatField()
  jackpot_currency = models.ForeignKey(Currency, related_name='jackpot_currency')
  block_price = models.FloatField()
  block_currency = models.ForeignKey(Currency, related_name='block_currency')
  draw_date = models.DateTimeField()
  template = models.TextField(max_length=500)

  class Meta:
    db_table = 'tbl_draws'
  
  